package com.ffsky.litepack.demo.data;


import android.app.Activity;
import android.content.Context;
import android.util.Log;
import android.widget.Toast;

import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.gitee.hljdrl.ffkit.app.FFKitAboutActivity;
import com.gitee.hljdrl.ffkit.bean.FFKitLink;
import com.gitee.hljdrl.ffkit.builder.FFKitLinkSource;
import com.gitee.hljdrl.ffkit.fragment.FFKitColorFragment;
import com.gitee.hljdrl.ffkit.listener.OnExecuteListener;
import com.gitee.hljdrl.lite.Lite;

import java.util.ArrayList;
import java.util.List;

public class MyLinkSource extends FFKitLinkSource {


    @Override
    public RecyclerView.LayoutManager getLayoutManager(Context context) {
        GridLayoutManager layoutManager = new GridLayoutManager(context, 1);//第二个参数为网格的列数
        return layoutManager;
    }

    @Override
    public List<FFKitLink> getList() {
        List<FFKitLink> list = new ArrayList<>();
        //----------------------------------------------------------------
        list.add(new FFKitLink.Builder().setName("Lite.task.post(Runnable run)").setOnExecuteListener(new OnExecuteListener() {
            @Override
            public void onExecute(Activity activity) {
                Lite.task.post(new Runnable() {
                    @Override
                    public void run() {
                        Log.i("post", "run....");
                    }
                });
            }
        }).build());
        //----------------------------------------------------------------
        list.add(new FFKitLink.Builder().setName("Lite.task.ui(Runnable run)").setOnExecuteListener(new OnExecuteListener() {
            @Override
            public void onExecute(Activity activity) {
                Lite.task.ui(new Runnable() {
                    @Override
                    public void run() {
                        Toast.makeText(activity, "Lite.task.ui-->Toast", Toast.LENGTH_SHORT).show();
                    }
                });
            }
        }).build());
        //----------------------------------------------------------------
        list.add(new FFKitLink.Builder().setName("Lite.task.uiTime(Runnable run, long time)").setOnExecuteListener(new OnExecuteListener() {
            @Override
            public void onExecute(Activity activity) {
                Lite.task.uiTime(new Runnable() {
                    @Override
                    public void run() {
                        Toast.makeText(activity, "Lite.task.uiTime-->Toast", Toast.LENGTH_SHORT).show();
                    }
                }, 2000);
            }
        }).build());
        //----------------------------------------------------------------
        list.add(new FFKitLink.Builder().setName("Lite.task.postQueue(Runnable run)").setOnExecuteListener(new OnExecuteListener() {
            @Override
            public void onExecute(Activity activity) {
                Lite.task.postQueue(new Runnable() {
                    @Override
                    public void run() {
                        Log.i("postQueue", "run....");
                    }
                });
            }
        }).build());
        //----------------------------------------------------------------
        return list;
    }

    @Override
    public String getAppName() {
        return "lite app";
    }
}
